package demo08.Facade_pattern.entity;
/**
 * cd实体
 * */
public class CdPlayer {
	String description;//描述
	int currentTrack;//电流跟踪
	Amplifier amplifier;//扩音器实体
	String title;//cd名
	
	public CdPlayer(String description, Amplifier amplifier) {
		this.description = description;
		this.amplifier = amplifier;
	}
 
	public void on() {
		System.out.println(description + " 打开");
	}
 
	public void off() {
		System.out.println(description + " 关闭");
	}

	public void eject() {
		title = null;
		System.out.println(description + " 弹出");
	}
 
	public void play(String title) {
		this.title = title;
		currentTrack = 0;
		System.out.println(description + " 播放 \"" + title + "\"");
	}

	public void play(int track) {
		if (title == null) {
			System.out.println(description + " can't play track " + currentTrack + 
					", 没有插入光盘");
		} else {
			currentTrack = track;
			System.out.println(description + " playing track" + currentTrack);
		}
	}

	public void stop() {
		currentTrack = 0;
		System.out.println(description + " 停止");
	}
 
	public void pause() {
		System.out.println(description + " 停下来 \"" + title + "\"");
	}
 
	public String toString() {
		return description;
	}
}
